package converter;

import fun.ltool.core.excel.convert.ExcelTypeConverter;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 示例 自定义数据类型转换器
 */
public class LocalDateExcelTypeConverter implements ExcelTypeConverter<LocalDate> {
    @Override
    public LocalDate convert(Object value, Class<?> fieldType) {
        if (value == null) {
            return null;
        }
        if (fieldType == LocalDate.class) {
            return LocalDate.parse(value.toString(), DateTimeFormatter.ofPattern("yyyyMMdd"));
        }
        return null;
    }
}
